package com.lhl.blog.common.utils;

import com.lhl.blog.common.pojo.dataobject.BlogInfo;
import com.lhl.blog.common.pojo.dataobject.UserInfo;
import com.lhl.blog.common.pojo.request.AddBlogInfoParam;
import com.lhl.blog.common.pojo.request.UpdateBlogInfoParam;
import com.lhl.blog.common.pojo.response.BlogInfoResponse;
import com.lhl.blog.common.pojo.response.UserInfoResponse;
import org.apache.tomcat.util.http.fileupload.disk.DiskFileItemFactory;
import org.springframework.beans.BeanUtils;

public class BeanConver {
    public static BlogInfoResponse tans(BlogInfo blogInfo){
        BlogInfoResponse blogResponse = new BlogInfoResponse();
        if(blogInfo != null){
            BeanUtils.copyProperties(blogInfo, blogResponse);
        }

        return blogResponse;
    }

    public static UserInfoResponse tans(UserInfo userInfo){
        UserInfoResponse userResponse = new UserInfoResponse();
        if(userInfo != null){
            BeanUtils.copyProperties(userInfo, userResponse);
        }
        return userResponse;
    }

    public static BlogInfo tans(AddBlogInfoParam param){
        BlogInfo blogInfo = new BlogInfo();
        BeanUtils.copyProperties(param,blogInfo);
        return blogInfo;
    }

    public static BlogInfo tans(UpdateBlogInfoParam param){
        BlogInfo blogInfo = new BlogInfo();
        BeanUtils.copyProperties(param,blogInfo);
        return blogInfo;
    }
}
